package logic

import (
	"context"
	"video/model/mysql"

	"video/videorpc/internal/svc"
	"video/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCommentListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentListLogic {
	return &CommentListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 评论列表
func (l *CommentListLogic) CommentList(in *videorpc.CommentListRequest) (*videorpc.CommentListResponse, error) {
	// todo: add your logic here and delete this line

	var show videorpc.CommentListResponse

	show = mysql.FirstVideoShow(mysql.DB, in.VideoId)

	var list []*videorpc.CommentList

	list = mysql.CommentList(mysql.DB, in)

	return &videorpc.CommentListResponse{
		Title:      show.Title,
		Category:   show.Category,
		Link:       show.Link,
		CoverLink:  show.CoverLink,
		Intro:      show.Intro,
		PlayNum:    show.PlayNum,
		LikeNum:    show.LikeNum,
		CollectNum: show.CollectNum,
		CommentNum: show.CommentNum,
		Status:     show.Status,
		UserId:     show.UserId,
		TopicId:    show.TopicId,
		VideoId:    show.VideoId,
		HeadImage:  show.HeadImage,
		NickName:   show.NickName,
		List:       list,
	}, nil
}
